import { Injectable } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';

@Injectable({
  providedIn: 'root'
})
export class ModalService {
  private timer: any;

  constructor(private message: NzMessageService) { }

  openModal(param): void {
    this.closeModal();
    this.showModal(param);
  }

  showModal(param): void {
    console.log(param);
    this.message.loading('这是一个警告提示弹窗', { nzDuration: 3000 });
    this.timer = setInterval(() => {
      this.message.loading('这是一个警告提示弹窗', { nzDuration: 3000 });
    }, 5000);
  }

  closeModal(): void {
    clearInterval(this.timer);
    this.message.remove();
  }
}